<?php
	require_once 'environment.php';
	//Admins only!
	if(!$acc->isLogged()) die(change_site("account.php"));
	$temp->addSubMenu("Change Front Page", "changeHomePage.php");
	$temp->currentPage("Home >> Change Front Page");
	$temp->setTab(0, 0);
	$temp->generate();
	
	if(!fixArr($_POST, "data")) {
		$sql = $db->Execute("SELECT * FROM `monster`.`frontPage` WHERE `AutoInc` = 1 LIMIT 1");
		if($sql->RecordCount() == 1) {
			//Well, if it's not one then there's a problem with the database, but still...
			$row = $sql->FetchRow();
			print "<form method=\"POST\" action=\"\">\n";
			print "<textarea name=\"data\" rows=\"20\" cols=\"60\">".$row['Text']."</textarea><br />\n";
			print "<input type=\"submit\" value=\"Update\" /> <input type=\"reset\" value=\"Reset\" />\n";
			print "</form>\n";
		}
	}else {
		$data = fixArr($_POST, "data");
		$data = stripslashes($data);
		$db->Execute("UPDATE `monster`.`frontPage` SET `Text` = ? WHERE `AutoInc` = '1' LIMIT 1", array($data));
		$acc->adminGPS("Changed home page.");
        print change_site("index.php");
	}
?>